#
# written by Pavel C <pavelch+dcbot@gmail.com>
# src site: https://code.google.com/p/dc-bot/
#echo off
#cd inter
#set PYTHONDIR=c:\Python27\
. /ffp/etc/ffp.subr
MOUNTP=/mnt/usb
path1=/ffp/bin
name="aibot"
perl_flags=" $path1/aibot_serv.pl -c utf8 -t $MOUNTP/data/bot/settings/helper.utf8.txt"
command="/ffp/bin/perl"
_su="su nobody"
required_files="$path1/aibot_serv.pl"

start_cmd="aibot_start_bg" 

aibot_start_bg()
{
	_cmd="perl"
        eval _flags=\$$(echo $_cmd | tr '.-' '_')_flags 
	mkdir -p /ffp/var/log
        _log=/ffp/var/log/$(echo $name).log 
        _pids=$(find_pids $_cmd)
        if test -z "$_pids"; then
            test -x "$command"     || die "$1: Not executable"
            echo "Starting $_su $command $_flags"
            su - nobody -c "$command $_flags 1>$_log 2>&1 </dev/null &"
        else
            warn "$_cmd: Already running"
        fi
        shift 1
    
    
} 
run_rc_command "$1"




